<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?=config_item('my_title')?></title>
    <base href="<?=base_url()?>">
    <link rel="stylesheet" href="plugin/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php require_once(VIEWPATH.'include/header.html');?>
<!-- 主内容区域 -->
<div class="container-fluid iframe-container">
    <?php require_once(VIEWPATH.'include/sidebar.html');?>
    <!-- 主面板 -->
    <div class="iframe-main">
        <div class="iframe-main-section">
            <div class="section_container">
                <div class="panel">
                    <div class="panel-heading">
                        <div class="panel-control pull-left">
                            <ul class="nav nav-tabs">
                                <?=$config_group_tabs?>
                            </ul>
                        </div>
                    </div>
                    <form class="form-horizontal ajax-form-hook" action="<?=$save_url?>" method="post">
                        <div class="panel-body">
                            <?php
                            foreach($config_item as $val):
                            $help_block = ($val['remark']=='') ? '' : '<span class="help-block">
                            '.$val['remark'].'</span>';
                            ?>
                            <div class="form-group">
                                <div class="col-xs-2 control-label"><?=$val['name']?></div>
                                <?php if($val['type']=='text'):?>
                                <div class="col-xs-6">
                                    <input type="text" name="<?=$val['variable']?>" value="<?=$val['val']?>"
                                           class="form-control">
                                    <?=$help_block?>
                                </div>
                                <?php elseif($val['type']=='radio'):?>
                                <div class="col-xs-6 radio">
                                    <?php
                                    foreach($val['param_arr'] as $item):
                                    $checked = ($val['val'] == $item['value']) ? 'checked' : '';
                                    ?>
                                    <label><input type="radio" name="<?=$val['variable']?>"
                                                  value="<?=$item['value']?>" <?=$checked?>>
                                        <ins><?=$item['name']?></ins>
                                    </label>
                                    <?php endforeach;?>
                                    <?=$help_block?>
                                </div>
                                <?php elseif($val['type']=='checkbox'):?>
                                <div class="col-xs-6 checkbox">
                                    <?php
                                foreach($val['param_arr'] as $item):
                                $checked = (in_array($item['value'],$val['val'])) ? 'checked' : '';
                                ?>
                                    <label><input type="checkbox" name="<?=$val['variable']?>[]"
                                                  value="<?=$item['value']?>" <?=$checked?>>
                                        <ins><?=$item['name']?></ins>
                                    </label>
                                    <?php endforeach;?>
                                    <?=$help_block?>
                                </div>
                                <?php elseif($val['type']=='select'):?>
                                <div class="col-xs-3">
                                    <select name="<?=$val['variable']?>" class="form-control">
                                        <option value="0">-请选择-</option>
                                        <?php
                                        foreach($val['param_arr'] as $item):
                                        $selected = ($val['val'] == $item['value']) ? 'selected' : '';
                                        ?>
                                        <option value="<?=$item['value']?>"
                                        <?=$selected?>><?=$item['name']?></option>
                                        <?php endforeach;?>
                                    </select>
                                    <?=$help_block?>
                                </div>
                                <?php elseif($val['type']=='textarea'):?>
                                <div class="col-xs-6">
                                <textarea name="<?=$val['variable']?>" class="form-control"
                                          rows="4"><?=$val['val']?></textarea>
                                    <?=$help_block?>
                                </div>
                                <?php endif; ?>
                                <div class="col-xs-2">
                                    <div class="form-control-static"><?=$val['variable']?></div>
                                </div>
                            </div>
                            <?php
                            endforeach;
                        ?>
                            <?php if(!empty($config_item)):?>
                            <div class="form-group">
                                <div class="col-xs-offset-2 col-xs-8">
                                    <?=$save_btn?>
                                </div>
                            </div>
                            <?php endif;?>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" src="plugin/require.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript">
    require(['unit'], function (unit) {
        unit.ajaxForm();
    });
</script>
</body>
</html>